﻿@using EC.Entity.Response.BankCard
@using EC.Entity.Enum
@using EC.Util

@model EC.Entity.PagedList<BankCardQueryResponse>
<div class="data-body data-scroll">
    <div class="data-view">
        <div class="data-div-view table-responsive">
            <table class="table table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th class="t_l">所属商户</th>
                        <th class="t_l wd75">组</th>
                        <th class="t_l wd100">银行名称</th>
                        <th class="t_l wd100">用户名</th>
                        <th class="t_l wd150">银行卡号</th>
                        <th class="t_c wd75">类型</th>
                        <th class="t_c wd75">是否冻结</th>
                        <th class="t_c wd75">状态</th>
                        <th class="t_c wd75">参考余额</th>
                        <th class="t_c wd75">日收款上限</th>
                        <th class="t_c wd130">更新时间</th>
                        <th class="t_c wd225">虚拟机编码</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null && Model.TData != null && Model.TData.Any())
                    {
                        foreach (var item in (IEnumerable<BankCardQueryResponse>)Model.TData)
                        {
                            //样式
                            string style = "";
                            //更新时间之差
                            double minutes = 0;
                            //最后更新时间
                            string balanceUpdateTime = "";

                            if (item.BalanceUpdateTime.HasValue)
                            {
                                minutes = DateTime.Now.Subtract(item.BalanceUpdateTime.Value).TotalMinutes;
                                balanceUpdateTime = item.BalanceUpdateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
                            }

                            if (minutes >= 3 && item.Status == (int)BankCardStatus.启用 && item.CardType != (int)CardType.备用卡)
                            {
                                style = "background-color:red;color:white;";
                            }
                    <tr>
                        <td class="t_l">
                            @{
                                if (item.MerchantId > 0)
                                {
                                    <span>@(item.ProxyMerchantName)</span>
                                }
                            }
                        </td>
                        <td class="t_l wd50">@(item.ProxyGroup)</td>
                        <td class="t_l wd100">@(item.BankName)</td>
                        <td class="t_l wd100">@(item.BankCardName)</td>
                        <td class="t_l wd150">@(item.BankCardNumber)</td>
                        <td class="t_c wd75">@(EnumUtil.GetDescription(typeof(CardType), item.CardType))</td>
                        <td class="t_c wd75">@(EnumUtil.GetDescription(typeof(BankCardFrozen), item.Frozen))</td>
                        <td class="t_c wd75">
                            @{
                                if (item.Status == (int)BankCardStatus.启用)
                                {
                                    <span class="green bold">启用</span>
                                }
                                else if (item.Status == (int)BankCardStatus.禁用)
                                {
                                    <span class="red bold">禁用</span>
                                }
                                else if (item.Status == (int)BankCardStatus.待用)
                                {
                                    <span style="color: blue" class="bold">待用</span>
                                }
                            }
                        </td>
                        <td class="t_r wd100">@(item.Balance)</td>
                        <td class="t_r wd100">@(item.UpperLimit)</td>
                        <td class="t_l wd130" style="@(style)">
                            @(balanceUpdateTime)
                        </td>
                        <td class="t_l wd225">
                            @(item.VmClientId)
                        </td>
                    </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td colspan="10" class="t_c">暂无记录</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
<!-- 必要的分页参数设置 -->
<input type="hidden" id="TotalCount" value="@(Model != null ? Model.TotalCount : 0)" />